/**
 * Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.muqi.app.im.ui;

import java.util.List;

import com.muqi.app.im.adapter.NewFriendsMsgAdapter;
import com.muqi.app.im.db.InviteMessgeDao;
import com.muqi.app.im.domain.InviteMessage;
import com.muqi.app.qlearn.student.BaseFragmentActivity;
import com.muqi.app.qlearn.student.R;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

/**
 * 申请与通知
 *
 */
public class NewFriendsMsgActivity extends BaseFragmentActivity {
	private ListView listView;
	private InviteMessgeDao dao;
	private List<InviteMessage> msgs;
	private NewFriendsMsgAdapter adapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.em_activity_new_friends_msg);
	}
	
	@Override
	protected void onInit() {
		listView = (ListView) findViewById(R.id.list);
	}

	@Override
	protected void onData() {
		dao = new InviteMessgeDao(this);
		dao.saveUnreadMessageCount(0);
	}
	
	@Override
	protected void onResume() {
		msgs = dao.getMessagesList();
		if(adapter==null){
			adapter = new NewFriendsMsgAdapter(this, 1, msgs); 
			listView.setAdapter(adapter);
		}else{
			adapter.notifyDataSetChanged();
		}
		super.onResume();
	}

	public void back(View view) {
		finish();
	}
}
